package com.jiaomatech.demo.order.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * Description: $VAL$ .<br>
 *
 * @author m-xy
 *     Created By 2019/10/18 15:53
 */
@Data
@ApiModel("操作结果")
public class OperationResultDto implements Serializable {
    @ApiModelProperty("是否成功")
    private boolean success = true;
    @ApiModelProperty("异常信息")
    private String message = "";
    @ApiModelProperty("返回数据")
    private Object data;

    /**
     * 成功.
     *
     * @return
     */
    public static OperationResultDto ok() {
        return new OperationResultDto();
    }

    /**
     * 成功.
     *
     * @param data
     * @return
     */
    public static OperationResultDto ok(Object data) {
        OperationResultDto operationResultDto = new OperationResultDto();
        operationResultDto.setData(data);
        return operationResultDto;
    }


    /**
     * 失败.
     *
     * @param message 异常信息
     * @return
     */
    public static OperationResultDto fail(String message) {
        OperationResultDto operationResultDto = new OperationResultDto();
        operationResultDto.setSuccess(false);
        operationResultDto.setMessage(message);
        return operationResultDto;
    }
}
